home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / mod2tutb.zip / STRINGEX.MOD < prev    next >
Text File  |  1989-01-18  |  2KB  |  67 lines

  1.                                          (* Chapter 6 - Program 6 *)
  2. MODULE StringEx;
  3.  
  4. (* Note - The "Strings" procedures used here are not standard because
  5.           there is no standard.  You may need to modify some or all
  6.           of the string procedure calls to get them to work.  Consult
  7.           the documentation for your compiler and library.         *)
  8.  
  9. FROM InOut   IMPORT WriteString, WriteInt, WriteLn;
  10. FROM Strings IMPORT Assign, Concat;
  11.  
  12. TYPE SevenChar = ARRAY[0..6] OF CHAR;
  13.  
  14. VAR Horse : ARRAY[0..12] OF CHAR;
  15.     Cow   : ARRAY[0..5] OF CHAR;
  16.     S1    : SevenChar;
  17.     S2    : SevenChar;
  18.     Index : CARDINAL;
  19.  
  20. (* ******************************************************* Display *)
  21. PROCEDURE Display(Stuff : ARRAY OF CHAR);
  22. BEGIN
  23.    WriteString("Array(");
  24.    WriteString(Stuff);
  25.    WriteString(") - ");
  26.    FOR Index := 0 TO HIGH(Stuff) DO
  27.       WriteInt(ORD(Stuff[Index]),4);
  28.    END;
  29.    WriteLn;
  30. END Display;
  31.  
  32. (* ************************************************** main program *)
  33. BEGIN
  34.    Horse := "ABCDEFGHIJKL";           (* Copy constant to variable *)
  35.    Display(Horse);
  36.  
  37.    Cow := "12345";
  38.    Assign(Cow,Horse);               (* Assign variable to variable *)
  39.    Display(Horse);
  40.  
  41.    S1 := "Neat";
  42.    S2 := "Things";
  43.    Concat(S1,S2,Horse);       (* Concatenate variables to variable *)
  44.    Display(Horse);
  45.    S1 := S2;                        (* Assign variable to variable *)
  46.  
  47.    Concat(Horse,Cow,Horse); (* Concatenate one variable to another *)
  48.    Display(Horse);
  49.  
  50.    Concat(Cow,Horse,Horse);        (* Concatenate to the beginning *)
  51.    Display(Horse);
  52. END StringEx.
  53.  
  54.  
  55.  
  56.  
  57. (* Result of execution
  58.  
  59. Array(ABCDEFGHIJKL) -   65  66  67  68  69  70  71  72  73  74  75  76   0
  60. Array(12345) -   49  50  51  52  53   0  71  72  73  74  75  76   0
  61. Array(NeatThings) -   78 101  97 116  84 104 105 110 103 115   0  76   0
  62. Array(NeatThings123) -   78 101  97 116  84 104 105 110 103 115  49  50  51
  63. Array(12345NeatThin) -   49  50  51  52  53  78 101  97 116  84 104 105 110
  64.  
  65. *)
  66.  
  67.